package com.itheima.tlias.mapper;


import com.itheima.tlias.pojo.Dept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * TODO
 *
 * @Author mr.luo
 * @Date 05 4月 2025 10:35
 */
@Mapper
public interface DeptMapper {
    /**
     * 查询所有部门
     *
     * @return
     */
    @Select("select * from dept")
    List<Dept> findAll();

    /**
     * 根据id删除部门
     *
     * @param
     */
    @Delete("delete from dept where id = #{id}")
    void delete(Integer id);
//    void delete(@Param("uid") Integer uid);

    /**
     * 添加部门
     *
     * @param dept
     */
    @Insert("insert into dept(name,create_time,update_time) values(#{name},#{createTime},#{updateTime})")
    void add(Dept dept);

    /**
     * 根据id查询部门
     *
     * @param uid
     * @return
     */
    @Select("select * from dept where id = #{uid}")
    Dept findById(Integer uid);

    @Insert("update dept set name = #{name},update_time = #{updateTime} where id = #{id}")
    void update(Dept dept);

    /**
     * 根据id查询部门下的员工信息
     * @param uid
     * @return
     */
    @Select("select * from emp where dept_id = #{uid}")
    List<Dept> findByIdEmp(Integer uid);
}
